package org.jeecg.modules.yw.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.yw.vo.OrderQueryVO;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@Mapper
public interface OrderQueryMapper extends BaseMapper<OrderQueryVO> {
	/**
	 * 得到订单
	 */
     public IPage<OrderQueryVO> getAllOrders(Page<OrderQueryVO> page, @Param(Constants.WRAPPER) QueryWrapper<OrderQueryVO> queryWrapper);
     
     
     
     @Select("SELECT id, orderNo,ownerName,ownerPhone,ownerAddress,yyTime,orderStatus,azsgStatus,djshStatus FROM `order` where createUserId = #{userId} and delFlag = 0 order by updateTime desc limit ${offset},${pageSize}")
     public List<OrderQueryVO> getOrderList(@Param("userId") String userId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
     
     @Select("SELECT id, orderNo,ownerName,ownerPhone,ownerAddress,yyTime,orderStatus,azsgStatus,djshStatus FROM `order` where azbzUserId = #{userId} or id in (select orderId from appointment where bzzId = #{userId}) and delFlag = 0  order by updateTime desc limit ${offset},${pageSize}")
     public List<OrderQueryVO> getOrderList1(@Param("userId") String userId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
     
     @Select("SELECT id, orderNo,ownerName,ownerPhone,ownerAddress,yyTime,orderStatus,azsgStatus,djshStatus FROM `order` where id in (select orderId from appointment where appointId = #{userId})  and delFlag = 0  order by updateTime desc limit ${offset},${pageSize}")
     public List<OrderQueryVO> getOrderList2(@Param("userId") String userId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
     
     
     @Select("SELECT id, orderNo,ownerName,ownerPhone,ownerAddress,yyTime,orderStatus,azsgStatus,djshStatus FROM `order` where djshUserId = #{userId})  and delFlag = 0  order by updateTime desc limit ${offset},${pageSize}")
     public List<OrderQueryVO> getOrderList3(@Param("userId") String userId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
     
     
     
}


